You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

23 lines
785 B

import { defineWrappedResponseHandler } from "#server/utils/handler";
import { R } from "#server/utils/response";
import { getAgentBySlug } from "#server/service/agent/agent";
import { agentRowToCard } from "#server/service/a2a/converter";
export default defineWrappedResponseHandler(async (event) => {
const agentSlug = getRouterParam(event, "agentSlug");
if (!agentSlug) {
return R.error("参数无效", null);
}
const agent = await getAgentBySlug(agentSlug);
if (!agent) {
return R.error("agent 不存在", null);
}
const protocol = event.node.req.headers["x-forwarded-proto"] ?? "http";
const host = event.node.req.headers.host ?? "localhost";
const baseUrl = `${protocol}://${host}`;
const card = agentRowToCard(agent, baseUrl);
return card;
});